#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e6;
int t,n,a[maxn],ans,b[maxn];
inline void dfs(int x)
{
    if (x == n)
    {
        int res = 0;
        for (register int i = 1 ; i <= n ; i++)
        {
            for (register int s = i - 1 ; s >= 1 ; s--)
            {
                if (b[i] == b[s] && a[i] == a[s])
                {
                    res += a[i];
                }
                else if (b[i] != b[s])
                {
                    break;
                }
            }
        }
        ans = max(ans,res);
        return;
    }
    b[x + 1] = 0;
    dfs(x + 1);
    b[x + 1] = 1;
    dfs(x + 1);
}
template <typename T>
inline void read(T & num)
{
    T f = 1,x = 0;
    char s = getchar();
    for (; s < '0' || s > '9' ; s = getchar())
    {
        if (s == '-')
        {
            f = -f;
        }
    }
    for (; s >= '0' && s <= '9' ; s = getchar())
    {
        x = (x << 3) + (x << 1) + (s ^ '0');
    }
    num = x * f;
}
template <typename T>
inline void print(T x)
{
    if (x < 0)
    {
        x = -x;
    }
    if (x > 10)
    {
        print(x / 10);
    }
    putchar(x % 10 + '0');
}
int main()
{
    freopen("color.in","r",stdin);
    freopen("color.out","w",stdout);
    read(t);
    while (t--)
    {
        read(n);
        ans = 0;
        for (register int i = 1 ; i <= n ; i++)
        {
            read(a[i]);
        }
        dfs(0);
        print(ans);
        printf("\n");
    }
    return 0;
}
